package cn.richx.pushmessage.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.Instant;

/**
 * 验证码
 * @author: Xiumin
 * @create: 2018/3/30
 */
@Entity
@Table(name = "kf_captcha", catalog = "uaa")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Captcha implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @NotNull
    @Size(max = 20)
    @Column(name = "phone", length = 20)
    private String phone; 	// 手机号

    @NotNull
    @Size(max = 10)
    @Column(name = "code", length = 10)
    private String code; 	// 验证码

    @NotNull
    @Max(value = 100000)
    @Column(name = "expire")
    private int expire;   //过期时间

    @NotNull
    @Column(name = "create_time")
    private Instant createTime;   //生成时间

    @NotNull
    @Column(name = "type")
    private int type;   //类型 1表示注册   2表示重置密码

    @NotNull
    @Column(name = "status")
    private int status;   //状态 0表示正在使用，1表示已使用过

    public Captcha() {
    }

    public Captcha(String phone, String code, int expire, Instant createTime, int type, int status) {
        this.phone = phone;
        this.code = code;
        this.expire = expire;
        this.createTime = createTime;
        this.type = type;
        this.status = status;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public int getExpire() {
        return expire;
    }

    public void setExpire(int expire) {
        this.expire = expire;
    }

    public Instant getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Instant createTime) {
        this.createTime = createTime;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }
}
